package com.yonyou.pmclouds.processphoto.service.rmiimpl;

import com.yonyou.pmclouds.alter.entity.AlterVO;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.processphoto.entity.ProcessPhotoVO;
import com.yonyou.pmclouds.processphoto.rmiitf.ProcessPhotoQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ReferenceCheckOfProcessPhoto implements ReferenceCheckOfBusiness{
    @Autowired
    private ProcessPhotoQuery query;
    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECT,RefCodeConst.PROCEDURE,RefCodeConst.PROJECTPART};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code = null;
        if(RefCodeConst.PROJECT.equals(bdCode)) {
            code = ProcessPhotoVO.PK_PROJECT;
        } else if(RefCodeConst.PROCEDURE.equals(bdCode)) {
            code = ProcessPhotoVO.PK_PROCESS;
        } else if(RefCodeConst.PROJECTPART.equals(bdCode)){
            code = ProcessPhotoVO.PK_PROJECTPART;
        } else {
            throw new BusinessException("工序拍照暂未引用该档案!");
        }
        return query.queryRefByIds(code, keys);
    }

}
